package ro.bluecube.admlocal.registruagricol.entity;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import ro.bluecube.admlocal.commons.PersistableEntity;

@Entity
@NamedQueries( {
		@NamedQuery(name = "findAllTitular", query = "SELECT T FROM Titular T"),
		@NamedQuery(name = "findByPozitie", query = "SELECT T FROM Titular T where T.pozitie = ?1"),
		@NamedQuery(name = "findByVolum", query = "SELECT T FROM Titular T where T.volum = ?1"),
		@NamedQuery(name = "findTitularById", query = "SELECT T FROM Titular T where T.id = ?1") })
@Table(name = "titulari")
public class Titular extends PersistableEntity {

	private static final long serialVersionUID = 1L;
	private Volum volum;

	public void setVolum(Volum volum) {
		this.volum = volum;
	}

	@JoinColumn(name="VOLUM_ID", referencedColumnName="ID")
	@ManyToOne
	public Volum getVolum() {
		return volum;
	}

	public void setPozitie(int pozitie) {
		this.pozitie = pozitie;
	}

	public int getPozitie() {
		return pozitie;
	}

	public void setLocalitate(Localitate localitate) {
		this.localitate = localitate;
	}
	
	@JoinColumn(name="LOCALITATE_ID", referencedColumnName="ID")
	@ManyToOne
	public Localitate getLocalitate() {
		return localitate;
	}
	
	private Localitate localitate;
	
	public void setRol(int rol) {
		this.rol = rol;
	}

	public int getRol() {
		return rol;
	}

	public void setStrada(String strada) {
		this.strada = strada;
	}

	public String getStrada() {
		return strada;
	}

	public void setNr(String nr) {
		this.nr = nr;
	}

	public String getNr() {
		return nr;
	}

	public void setMembri(Set<MembruGospodarie> membri) {
		this.membri = membri;
	}

	@OneToMany(mappedBy="id")
	public Set<MembruGospodarie> getMembri() {
		return membri;
	}

	public void setTerenuri(Set<Teren> terenuri) {
		this.terenuri = terenuri;
	}

	@OneToMany(mappedBy="id")
	public Set<Teren> getTerenuri() {
		return terenuri;
	}

	private int pozitie;

	private int rol;
	
	private String strada;
	private String nr;
	
	private Set<MembruGospodarie> membri;
	private Set<Teren> terenuri;
}